#!/usr/bin/env python3
# -*- coding: utf-8 -*-

'使用Handler设置代理'

from urllib import request

proxy_handler = request.ProxyHandler({'http':'http://www.example.com:3128'})
proxy_auth_handler = request.ProxyBasicAuthHandler()
proxy_auth_handler.add_password('realm','host','username','password')
opener = request.build_opener(proxy_handler,proxy_auth_handler)
with opener.open('http://www.example.com/login.html') as f:
    pass






